apply plugin: 'com.android.application'

<#assign applicationId=packageName>
android {
    compileSdkVersion rootProject.ext.build_versions.compile_version
    buildToolsVersion rootProject.ext.build_versions.build_tools

    defaultConfig {
        applicationId "${applicationId}"
        //到versions.gradle修改相应信息
        minSdkVersion rootProject.ext.build_versions.min_sdk
        targetSdkVersion rootProject.ext.build_versions.target_sdk
        versionCode 1
        versionName "1.0"

        manifestPlaceholders = [
            appLabel     : "AndroidApp"
        ]

        buildConfigField "boolean", "DEV_MODE", "false"
        buildConfigField "String", "DATA_PATH", '"YourDir"' //app 数据保存目录

        //使用项目正式域名替换
        buildConfigField "String", "API_BASE_URL", '"https://xxx"'

        ndk{
            abiFilters "armeabi-v7a"
        }

     	javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
                arguments = [ AROUTER_MODULE_NAME : project.getName() ]
            }
        }
    }

    sourceSets {
        main {
            // 指定so库地址
            jniLibs.srcDirs = ['jniLibs']
        }
    }

    //建议使用VERSION_1_8
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        debug {
            buildConfigField "boolean", "DEV_MODE", "true"
        }

        release {
            zipAlignEnabled true
            minifyEnabled true
            shrinkResources true

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "YourDimensions"
    productFlavors {
    	//测试环境
    	DEV {
      		dimension "YourDimensions"
    		  applicationId "${applicationId}.dev"
     		  manifestPlaceholders = [
    			  appLabel		: "AndroidAppDEV"
    		  ]

          //  使用项目测试域名替换
    		  buildConfigField "String", "API_BASE_URL", '"https://xxx.stg"'
    	}
    	//线上环境
    	PROD {
    		dimension "YourDimensions"
    	}
    }

    //定义各渠道的channel name
    productFlavors.all { flavor ->
        flavor.manifestPlaceholders.put("CHANNEL_VALUE",name)
    }

    //统一support库版本
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion rootProject.ext.versions.support_version
                }
            }
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}

// 可导入aar包
repositories {
    flatDir() {
        dirs 'libs'
    }
}